package com.xuecheng.media.conver;

import com.xuecheng.content.model.dto.MediaFilesTaskDto;
import com.xuecheng.content.model.dto.MultPartFileInfoInit;
import com.xuecheng.content.model.po.MediaFiles;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

public class MediaFilesConver {

    public static MediaFiles multPartFileInfoInitConverToMediaFiles(MultPartFileInfoInit fileInfo, MediaFiles mediaFileInsert) {
        BeanUtils.copyProperties(fileInfo, mediaFileInsert);
//            Optional.ofNullable(fileInfo.getBucketName()).filter(bucketName -> bucketName.equals(BUCKET_FILES)).ifPresent(bucketName -> mediaFileInsert.setTags("资源文件"));
//            Optional.ofNullable(fileInfo.getBucketName()).filter(bucketName -> bucketName.equals(BUCKET_VIDEOS)).ifPresent(bucketName -> mediaFileInsert.setTags("课程视频"));
//        mediaFileInsert.setId(fileInfo.getFileMD5());
        mediaFileInsert.setBucket(fileInfo.getBucketName());
        mediaFileInsert.setFileId(fileInfo.getFileMD5());
        mediaFileInsert.setUrl(fileInfo.getBucketName() + "/" + mediaFileInsert.getFilePath());
        mediaFileInsert.setCreateDate(LocalDateTime.now());
        mediaFileInsert.setChangeDate(LocalDateTime.now());
        mediaFileInsert.setAuditStatus("202002");
        mediaFileInsert.setFilename(fileInfo.getFileName());
        mediaFileInsert.setCompanyId(1232141425L);
        mediaFileInsert.setCompanyName("学成开发部门2307");
        String fileTypeCode = "video/bytes".equals(fileInfo.getFileType()) ? "001002" : "001001";
        mediaFileInsert.setFileType(fileTypeCode);

        return mediaFileInsert;
    }


}